<!DOCTYPE html>
<html lang="zh_CN">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div id="demo"></div>
	<div id="test"></div>


	<script type="text/javascript">
		// 6:
		var A = function(selector) {
		    return new A.fn.init(selector);
		}
		A.fn = A.prototype = {
			constructor: A,
		    init: function(selector) {
		    	console.log(this.constructor);
		    	this[0] = document.getElementById(selector);
		        this.length = 1;
		        return this;
		    },
		    length: 2,
		    size: function() {
		        return this.length;
		    }
		}
		// 改进：修改init的原型链
		A.fn.init.prototype = A.fn;
		// 测试
		console.log(A('demo').size());
	</script>
</body>
</html>